import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:jd_flutter/base/foundation/jd_colors.dart';

import 'checkbox_button.dart';

class AgreementTextWidget extends StatefulWidget {
  final ValueChanged<bool>? onChanged;

  const AgreementTextWidget({super.key, this.onChanged});

  @override
  State<AgreementTextWidget> createState() => _AgreementTextWidgetState();
}

class _AgreementTextWidgetState extends State<AgreementTextWidget> {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        mainAxisSize: MainAxisSize.min,
        children: [
          CheckboxButton(
            valueChanged: (selected) {
              widget.onChanged?.call(selected);
            },
            size: 14,
            padding: const EdgeInsets.only(right: 5, top: 9, bottom: 15),
          ),
          Flexible(
            child: Padding(
              padding: const EdgeInsets.only(top: 7),
              child: Text.rich(
                TextSpan(text: '登录同意', children: [
                  TextSpan(
                      text: '《用户协议》',
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          // RouterContractPage.instance.webViewPage.push(context, {
                          //   "title": "用户服务协议",
                          //   "url": kConfigKeys.registerAgreement,
                          // });
                        },
                      style:
                          const TextStyle(color: Colors.green, fontSize: 11)),
                  const TextSpan(text: '和'),
                  TextSpan(
                    text: '《隐私协议》',
                    recognizer: TapGestureRecognizer()
                      ..onTap = () {
                        // RouterContractPage.instance.webViewPage.push(context, {
                        //   "title": "用户隐私政策",
                        //   "url": kConfigKeys.privacyAgreement,
                        // });
                      },
                    style: const TextStyle(color: Colors.green, fontSize: 11),
                  ),
                ]),
                style: const TextStyle(color: JDColors.c999999, fontSize: 11),
              ),
            ),
          ),
        ]);
  }
}
